package cn.liuhuan1.blogsModel.controller;

import cn.liuhuan1.entity.ReturnResult;
import cn.liuhuan1.webModelBean.api.LeaveWordImp;
import cn.liuhuan1.webModelBean.api.NaswerImp;
import cn.liuhuan1.webModelBean.bo.AnswerBo;
import cn.liuhuan1.webModelBean.vo.AnswerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: liuhuan
 * @Date: 2021/4/5 - 04 - 05 - 3:08
 * @Description:
 * @version: 1.0
 */

@RequestMapping("/answer")
@Controller
public class AnswerController {

    @Autowired
    private NaswerImp naswerImp;

    @RequestMapping(value = "/saveAnswer",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult saveAnswer(@RequestBody AnswerBo naswerBo){
        naswerImp.saveAnswer(naswerBo);
        return ReturnResult.succes();
    }

    @RequestMapping(value = "/loadAnswerList",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult loadAnswerList(@RequestParam("id") String id){
        List<AnswerVo> answerVoList = naswerImp.loadAnswerList(id);
        return ReturnResult.succes(answerVoList);
    }

    @RequestMapping(value = "/delById",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult delById(@RequestParam("id") String id){
        naswerImp.delById(id);
        return ReturnResult.succes();
    }
}
